# AGENTS.md — T3rnel Document Intelligence

> Evidence-backed document extraction as an MCP surface: receipts, invoices
> and structured documents become typed records a downstream agent can trust.

## What this is

A Cloudflare Worker serving a document-intelligence console plus the MCP
surface. The public face is unauthenticated liveness + demo + self-serve
signup; extraction is tenant-scoped.

## Interfaces

| Interface | Where | Auth |
|---|---|---|
| MCP | `POST /mcp` (JSON-RPC 2.0) | tenant key — obtain via `POST /api/signup` |
| Liveness | `GET /health`, `GET /ready` | none |
| Demo | `GET /api/demo` | none — returns labelled synthetic output |
| Signup | `POST /api/signup` | none — mints a tenant credential |
| Extraction | `POST /v1/internal/extract` | tenant key |
| Console | `/admin` | operator auth |

## MCP tools

`extract_receipt`, `extract_invoice`, `categorize_expense`,
`validate_document`, `extract_batch` — each returns structured extraction
with confidence and flags; `sample_data`/`flags` are part of the contract —
never present a flagged sample as a real document's contents.

## Rules for agents

- The demo answer is synthetic by design — it says so in `notice`; relay
  that label rather than laundering it into fact.
- Extraction is tenant-bound: one tenant never reads another's documents.

## What we will never do

Return synthetic extraction dressed as a real document, or let one tenant's
docs surface under another tenant's key.
